package ru.ifmo.swing.genetics;

import org.uncommons.maths.number.NumberGenerator;
import ru.ifmo.automaton.Automaton;
import ru.ifmo.common.Source;
import ru.ifmo.genetics.automaton.synchronizeable.MaxLengthCalculator;
import ru.ifmo.swing.ProgressStartListener;

/**
 * @author avhaliullin
 */
public class MaxLengthProvider implements NumberGenerator<Integer>, ProgressStartListener {
    private int value = 0;
    private final Source<Automaton> automatonSource;

    public MaxLengthProvider(Source<Automaton> automatonSource) {
        this.automatonSource = automatonSource;
    }

    public Integer nextValue() {
        return value;
    }

    public void progressStarted() {
        value = MaxLengthCalculator.standardMaxLength(automatonSource.create());
    }
}
